package com.ysdzz.hadoop;

import java.io.IOException;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;

/**
 * Hello world!
 *
 */
public class App 
{
    public static void main( String[] args ) throws IOException, ClassNotFoundException, InterruptedException
    {
    	Configuration conf = new Configuration();
    	Job job = Job.getInstance(conf);
    	job.setJarByClass(App.class);
    	job.setJobName("UserCity");
    	
    	job.setMapperClass(UserCityMapper.class);
    	job.setReducerClass(UserCityReducer.class);
    	
    	job.setMapOutputKeyClass(Text.class);
    	job.setMapOutputValueClass(LongWritable.class);
    	
    	job.setOutputKeyClass(Text.class);
    	job.setOutputValueClass(LongWritable.class);
    	
    	FileInputFormat.addInputPath(job, new Path(args[0]));
    	FileOutputFormat.setOutputPath(job, new Path(args[1]));
    	
    	int extcode = job.waitForCompletion(true)?0:1;
    	System.exit(extcode);
    	
    }
}
